// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Requests;
using Elastic.Clients.Elasticsearch.Serialization;
using Elastic.Transport;
using Elastic.Transport.Extensions;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Security;

public sealed partial class SamlCompleteLogoutRequestParameters : RequestParameters
{
}

/// <summary>
/// <para>
/// Verifies the logout response sent from the SAML IdP.
/// </para>
/// </summary>
public sealed partial class SamlCompleteLogoutRequest : PlainRequest<SamlCompleteLogoutRequestParameters>
{
	internal override ApiUrls ApiUrls => ApiUrlLookup.SecuritySamlCompleteLogout;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => true;

	internal override string OperationName => "security.saml_complete_logout";

	/// <summary>
	/// <para>
	/// If the SAML IdP sends the logout response with the HTTP-Post binding, this field must be set to the value of the SAMLResponse form parameter from the logout response.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("content")]
	public string? Content { get; set; }

	/// <summary>
	/// <para>
	/// A json array with all the valid SAML Request Ids that the caller of the API has for the current user.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("ids")]
	public Elastic.Clients.Elasticsearch.Ids Ids { get; set; }

	/// <summary>
	/// <para>
	/// If the SAML IdP sends the logout response with the HTTP-Redirect binding, this field must be set to the query string of the redirect URI.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("query_string")]
	public string? QueryString { get; set; }

	/// <summary>
	/// <para>
	/// The name of the SAML realm in Elasticsearch for which the configuration is used to verify the logout response.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("realm")]
	public string Realm { get; set; }
}

/// <summary>
/// <para>
/// Verifies the logout response sent from the SAML IdP.
/// </para>
/// </summary>
public sealed partial class SamlCompleteLogoutRequestDescriptor : RequestDescriptor<SamlCompleteLogoutRequestDescriptor, SamlCompleteLogoutRequestParameters>
{
	internal SamlCompleteLogoutRequestDescriptor(Action<SamlCompleteLogoutRequestDescriptor> configure) => configure.Invoke(this);

	public SamlCompleteLogoutRequestDescriptor()
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.SecuritySamlCompleteLogout;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => true;

	internal override string OperationName => "security.saml_complete_logout";

	private string? ContentValue { get; set; }
	private Elastic.Clients.Elasticsearch.Ids IdsValue { get; set; }
	private string? QueryStringValue { get; set; }
	private string RealmValue { get; set; }

	/// <summary>
	/// <para>
	/// If the SAML IdP sends the logout response with the HTTP-Post binding, this field must be set to the value of the SAMLResponse form parameter from the logout response.
	/// </para>
	/// </summary>
	public SamlCompleteLogoutRequestDescriptor Content(string? content)
	{
		ContentValue = content;
		return Self;
	}

	/// <summary>
	/// <para>
	/// A json array with all the valid SAML Request Ids that the caller of the API has for the current user.
	/// </para>
	/// </summary>
	public SamlCompleteLogoutRequestDescriptor Ids(Elastic.Clients.Elasticsearch.Ids ids)
	{
		IdsValue = ids;
		return Self;
	}

	/// <summary>
	/// <para>
	/// If the SAML IdP sends the logout response with the HTTP-Redirect binding, this field must be set to the query string of the redirect URI.
	/// </para>
	/// </summary>
	public SamlCompleteLogoutRequestDescriptor QueryString(string? queryString)
	{
		QueryStringValue = queryString;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The name of the SAML realm in Elasticsearch for which the configuration is used to verify the logout response.
	/// </para>
	/// </summary>
	public SamlCompleteLogoutRequestDescriptor Realm(string realm)
	{
		RealmValue = realm;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (!string.IsNullOrEmpty(ContentValue))
		{
			writer.WritePropertyName("content");
			writer.WriteStringValue(ContentValue);
		}

		writer.WritePropertyName("ids");
		JsonSerializer.Serialize(writer, IdsValue, options);
		if (!string.IsNullOrEmpty(QueryStringValue))
		{
			writer.WritePropertyName("query_string");
			writer.WriteStringValue(QueryStringValue);
		}

		writer.WritePropertyName("realm");
		writer.WriteStringValue(RealmValue);
		writer.WriteEndObject();
	}
}